import React from 'react'
import Top from '../componets/top'
import Bottom from '../componets/bottom'
import {useState,useEffect} from "react"
import axios from 'axios'
// 在react得函数组件中，没有生命周期，需要借助一共hooks来模拟生命周期，一般用useEffect来模拟生命周期
function App() {
  let [arr,setArr] = useState([])
  useEffect(()=>{  // 相当于vue得mountd，相当于类组件得componentDidmounted
    console.log("我自己执行了");
    axios.get("/list1").then(res=>{
       console.log(res.data);
       setArr(res.data)
    })
    // setTimeout(()=>{  setArr([])},5000)
  },[])
  return (
    <div className='appwrap'>
      {
         arr && arr.length ?  <Top send = {arr}></Top> :"暂无数据"
      }
      {
          arr && arr.length ?   <Bottom  send = {arr}></Bottom> :"暂无数据"
      }
       
       
    </div>
  )
}

export default App